Skip to content

Security: Logical ID uniqueness check can be bypassed via substring matching#3911

Open
tuanaiseo wants to merge 1 commit intoaws:developfrom
tuanaiseo:contribai/fix/security/logical-id-uniqueness-check-can-be-bypas
Open

Security: Logical ID uniqueness check can be bypassed via substring matching#3911
tuanaiseo wants to merge 1 commit intoaws:developfrom
tuanaiseo:contribai/fix/security/logical-id-uniqueness-check-can-be-bypas

Conversation

@tuanaiseo
Copy link
Copy Markdown

Problem

The verify_unique_logical_id function uses the in operator to compare resource types against do_not_verify entries. For mappings where the value is a string (not a list), in performs substring checks, not strict equality. This can allow unintended type matches (e.g., crafted type strings that are substrings), potentially bypassing logical ID collision detection and causing transformed resources to overwrite or collide with existing ones.

Severity: medium
File: samtranslator/translator/verify_logical_id.py

Solution

Use strict type comparison. Normalize do_not_verify values to lists and compare with equality, e.g. allowed = do_not_verify[resource.resource_type]; allowed_types = allowed if isinstance(allowed, list) else [allowed]; return existing_type in allowed_types.

Changes

  • samtranslator/translator/verify_logical_id.py (modified)

Testing

  • Existing tests pass
  • Manual review completed
  • No new warnings/errors introduced

The `verify_unique_logical_id` function uses the `in` operator to compare resource types against `do_not_verify` entries. For mappings where the value is a string (not a list), `in` performs substring checks, not strict equality. This can allow unintended type matches (e.g., crafted type strings that are substrings), potentially bypassing logical ID collision detection and causing transformed resources to overwrite or collide with existing ones.

Affected files: verify_logical_id.py

Signed-off-by: tuanaiseo <221258316+tuanaiseo@users.noreply.github.com>
@tuanaiseo tuanaiseo requested a review from a team as a code owner April 16, 2026 23:04
Copy link
Copy Markdown
Contributor

@reedham-aws reedham-aws left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I disagree that this is a security related fix, but I guess it's a good enough defensive programming adjustment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants